//
//  DSConnect.h
//  MyClient
//
//  Created by lin on 16/3/22.
//  Copyright © 2016年 lin. All rights reserved.
//

#import <Foundation/Foundation.h>

@class DSConnect;

@protocol DSConnectDelegate <NSObject>

@optional
- (void)connectSuccess:(DSConnect *)connect;
- (void)connectFail:(DSConnect *)connect;

@end

@class GCDAsyncSocket;

@interface DSConnect : NSObject <NSNetServiceBrowserDelegate, NSNetServiceDelegate>
{
    NSNetServiceBrowser *netServiceBrowser;
    NSNetService *serverService;
    NSMutableArray *serverAddresses;
}

@property (nonatomic, readonly, assign) BOOL connected;
@property (nonatomic, readonly, strong) GCDAsyncSocket *asyncSocket;
@property (nonatomic, readwrite, weak) id<DSConnectDelegate> delegate;

+ (DSConnect *)sharedDSConnect;

/*
 *  开始连接
 */
- (void)start;

/*
 *  停止连接
 */
- (void)stop;

/*
 *  重新连接
 */
- (void)reConnect;

@end
